<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<style>
    .main{margin:0 auto;width:980px;border:1px dashed }
    .title{line-height:25px; text-align:center; font-size:18px; font-weight:500}
    pre{text-indent: 2em; margin:20px auto 10px 20px;}
</style>
<title></title>
</head>
<body>
<div class="main">
<%
	String MYSQLDRIVER = "com.mysql.jdbc.Driver";//MYSQL驱动
    //Mysql连接字符串
    String MYSQLURL = "jdbc:mysql://localhost:3306/ylog?user=root&password=caonimei&useUnicode=true&characterEncoding=utf8&autoReconnect=true";
    String sql = "SELECT * from wps_posts where post_id = "+request.getParameter("id");//查询语句
    out.println(sql+"<br/>");
    try {
        Class.forName(MYSQLDRIVER);//加载MYSQL驱动
        Connection conn = DriverManager.getConnection(MYSQLURL);//获取数据库连接
        PreparedStatement pstt = conn.prepareStatement(sql);
        ResultSet rs = pstt.executeQuery();
    	out.println("<font color=red>"+sql+"</font>");
        while(rs.next()){//结果遍历
        	out.println("<div class=title>"+rs.getObject("post_title")+"</div>");
        	out.println("<pre>"+rs.getObject("post_content")+"</pre>");
        }
        rs.close();//关闭查询结果集
        pstt.close();//关闭PreparedStatement
        conn.close();//关闭数据连接
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (SQLException e) {
        e.printStackTrace();
    }
%>
</div>
</body>
</html>